package cn.swing.learning;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Desc : TODO
 * ClassName : cn.swing.learning.MineMenuBar
 *
 * @author : 林鹏群
 * @date : 2022/12/20 14:06
 */
public class MineMenuBar extends JMenuBar {

    private MineFrame mineFrame;

    private JMenu game;
    private JMenu help;


    public MineMenuBar(MineFrame mineFrame) {
        this.mineFrame = mineFrame;

        game = new JMenu("游戏");
        help = new JMenu("帮助");

        JMenuItem start = new JMenuItem("开局");
        JMenuItem chuji = new JMenuItem("初级");
        JMenuItem zhongji = new JMenuItem("中级");
        JMenuItem tuichu = new JMenuItem("退出");
        game.add(start);
        game.add(chuji);
        game.add(zhongji);
        game.add(tuichu);

        start.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println(123456);
            }
        });
        chuji.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                mineFrame.getMineState().getTimer().start();
            }
        });
        zhongji.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Tools.zhongji();
                mineFrame.restart();
            }
        });

        tuichu.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });

        this.add(game);
        this.add(help);

    }
}
